PATHMac OS 8 and 9 Developer Documentation > Interapplication Communication > AppleScript for Scripters >

AppleScript Language Guide

   

Complete and Partial References

A complete reference has enough information to identify an object or objects uniquely. For a reference to an application object to be complete, its outermost container must be the application itself, as in

version of application "Finder" --result: "8.5"

In contrast, partial references do not specify enough information to identify an object or objects uniquely; for example:

delete file 1 of disk 4

When AppleScript encounters a partial reference, it attempts to use the default target specified in the Tell statement to complete the reference. The default target of a Tell statement is the object that receives commands if no other object is specified. For example, the following Tell statement tells the Finder to delete the first file of the fourth disk, using the previous partial reference.

tell application "Finder"
    delete file 1 of disk 4
end tell

Similarly, the following Tell statement tells the front document of the application AppleWorks to get the style of its text.

tell document 1 of application "AppleWorks"
    get style of text body
end tell

Tell statements can contain other Tell statements, called nested Tell statements. When AppleScript encounters a partial reference in a nested Tell statement, it tries to complete the reference starting with the innermost Tell statement. If that does not provide enough information, AppleScript uses the direct object of the next Tell statement, and so on. For example, the following Tell statement is equivalent to the previous Finder example.

tell application "Finder"
    tell file 1 of disk 4
        delete
    end tell
end tell

This example works because all of the nested statements target the same application, the Finder. For information on restrictions in using nested Tell statements, see Tell Statements.


© 1999 Apple Computer, Inc. – (Last Updated 21 May 99)